//
//  SWDicoverController.swift
//  SinaWeibo
//
//  Created by wszyxc on 16/7/17.
//  Copyright © 2016年 wszyxc. All rights reserved.
//

import UIKit

import SnapKit

class SWDicoverController: SWBaseController {
    
    override func loadView() {
        super.loadView()
    }

    override func viewDidLoad() {
        super.viewDidLoad()
        
        //设置界面
        setupUI()
        
        //设置约束
        setupLayout()
    }
    
    private func setupUI(){
        
        self.navigationItem.titleView = searchField
        
        

    }
    
    private func setupLayout(){
        
       searchField.snp_makeConstraints { (make) -> Void in
        
        make.leading.equalTo(20)
        make.top.equalTo(5)
        make.trailing.equalTo(-20)
        make.height.equalTo(30)
        
        }
        
    }
    
    //懒加载textField
   private lazy var searchField:UITextField = {
        
        var field = UITextField()
        
        field.placeholder = "大家正在搜.."
    
        field.background =  UIImage(named: "searchbar_textfield_background")
    
        field.layer.cornerRadius = 10
   
        field.layer.borderWidth = 2
    
        field.layer.borderColor = UIColor.redColor().CGColor
    
        field.leftView = self.leftView
    
        field.leftViewMode = .Always
    
        field.leftView?.contentMode = .Center
  
        return field
    }()
    
    private lazy var leftView:UIImageView = {
    
        var iconImageView = UIImageView(image: UIImage(named: "searchbar_textfield_search_icon")?.imageWithRenderingMode(.AlwaysOriginal))
        
        iconImageView.bounds = CGRect(x: 0, y: 0, width: 30, height: 30)
        
        return iconImageView
    }()
    
    
}
